package cn.edu.neusoft.fragment112gxl.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.fragment112gxl.R;
import cn.edu.neusoft.fragment112gxl.adapter.MyAdapter;
import cn.edu.neusoft.fragment112gxl.bean.ArticleBean;
import cn.edu.neusoft.fragment112gxl.iface.ArticleListener;
import cn.edu.neusoft.fragment112gxl.model.ArticleModel;

public class WeixinFragment extends Fragment {

    private View view;
    private Context context;
    RecyclerView recyclerView;
    RecyclerView.LayoutManager layoutManager;
    MyAdapter myAdapter;
    List<ArticleBean> list = null;
    ArticleListener articleListener = new ArticleListener(){

        @Override
        public void onResponse(List<ArticleBean> blist) {
            list =blist;
            myAdapter.setList(list);
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
        }
    };



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       context = getContext();
        view = inflater.inflate(R.layout.wfragment,container,false);
//        tvinfo = (TextView)view.findViewById(R.id.w);
//        tvinfo.setText("微信");
        recyclerView = (RecyclerView)view.findViewById(R.id.recycleView);
        layoutManager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);

        myAdapter = new MyAdapter(context);
        myAdapter.setList(list);
        recyclerView.setAdapter(myAdapter);

        ArticleModel articleModel = new ArticleModel();
        articleModel.getResultList("article",2,"2ts2j910hv4m270hipde4a67d7",articleListener);

        return view;
    }

}
